package com.xl.basic.config;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import com.xl.basic.entity.Properties;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 钟勇
 * Create in 2024/1/24 10:48
 */
@Configuration
@RequiredArgsConstructor
public class WxPaymentConfig {

    private final Properties prop;

    @Bean
    public WxPayService wxPayService() {
        Properties.WxPay wxPay = prop.getWxPay();
        WxPayConfig payConfig = new WxPayConfig();
        payConfig.setAppId(wxPay.getAppId());
        payConfig.setMchId(wxPay.getMchId());
        payConfig.setMchKey(wxPay.getMchKey());
        payConfig.setKeyPath(wxPay.getKeyPath());

        WxPayService wxPayService = new WxPayServiceImpl();
        wxPayService.setConfig(payConfig);
        return wxPayService;

    }
}
